package com.chainshop.controller;

/**
 * @author Administrator
 * @version 1.0
 * @title A
 * @description
 * @create 2024/8/13 19:46
 */

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.chainshop.common.core.domain.entity.SysUser;
import com.chainshop.pojo.EmployeePositions;
import com.chainshop.service.IEmployeePositionsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chainshop.common.annotation.Log;
import com.chainshop.common.core.controller.BaseController;
import com.chainshop.common.core.domain.AjaxResult;
import com.chainshop.common.enums.BusinessType;
import com.chainshop.common.utils.poi.ExcelUtil;
import com.chainshop.common.core.page.TableDataInfo;

/**
 * 存储岗位信息的Controller
 *
 * @author ruoyi
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/system/positions")
public class EmployeePositionsController extends BaseController
{
    @Autowired
    private IEmployeePositionsService employeePositionsService;

    /**
     * 查询存储岗位信息的列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmployeePositions employeePositions)
    {
        startPage();
        List<EmployeePositions> list = employeePositionsService.selectEmployeePositionsList(employeePositions);
        TableDataInfo dataTable = getDataTable(list);
        return dataTable;
    }

    /**
     * 导出存储岗位信息的列表
     */
    @PreAuthorize("@ss.hasPermi('system:positions:export')")
    @Log(title = "存储岗位信息的", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmployeePositions employeePositions)
    {
        List<EmployeePositions> list = employeePositionsService.selectEmployeePositionsList(employeePositions);
        ExcelUtil<EmployeePositions> util = new ExcelUtil<EmployeePositions>(EmployeePositions.class);
        util.exportExcel(response, list, "存储岗位信息的数据");
    }

    /**
     * 获取存储岗位信息的详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:positions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(employeePositionsService.selectEmployeePositionsById(id));
    }

    /**
     * 新增存储岗位信息的
     */
    @PreAuthorize("@ss.hasPermi('system:positions:add')")
    @Log(title = "存储岗位信息的", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmployeePositions employeePositions)
    {
        return toAjax(employeePositionsService.insertEmployeePositions(employeePositions));
    }

    /**
     * 修改存储岗位信息的
     */
    @PreAuthorize("@ss.hasPermi('system:positions:edit')")
    @Log(title = "存储岗位信息的", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmployeePositions employeePositions)
    {
        return toAjax(employeePositionsService.updateEmployeePositions(employeePositions));
    }

    /**
     * 删除存储岗位信息的
     */
    @PreAuthorize("@ss.hasPermi('system:positions:remove')")
    @Log(title = "存储岗位信息的", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(employeePositionsService.deleteEmployeePositionsByIds(ids));
    }
}
